import 'package:flutter/material.dart';

class ForgetPage extends StatelessWidget {
  final TextEditingController usernameController = TextEditingController();
  final TextEditingController phoneController = TextEditingController();
  final TextEditingController newPasswordController = TextEditingController();

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('\u5fd8\u8bb0\u5bc6\u7801'), // "忘记密码"
        backgroundColor: Colors.white,
      ),
      body: Container(
        decoration: const BoxDecoration(
          image: DecorationImage(
            image: NetworkImage(
                'https://pica.zhimg.com/80/v2-fa1ed7948fe0f3feedc69f6076abe789_720w.webp?source=1def8aca'),
            fit: BoxFit.cover,
          ),
        ),
        child: Padding(
          padding: const EdgeInsets.all(20),
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              // 用户名输入框
              Container(
                decoration: BoxDecoration(
                  color: Colors.white.withOpacity(0.8),
                  borderRadius: BorderRadius.circular(10),
                ),
                child: TextField(
                  controller: usernameController,
                  decoration: const InputDecoration(
                    labelText: '\u7528\u6237\u540d', // "用户名"
                    border: OutlineInputBorder(),
                  ),
                ),
              ),
              const SizedBox(height: 20),
              // 手机号输入框
              Container(
                decoration: BoxDecoration(
                  color: Colors.white.withOpacity(0.8),
                  borderRadius: BorderRadius.circular(10),
                ),
                child: TextField(
                  controller: phoneController,
                  keyboardType: TextInputType.phone, // 设置键盘类型为电话号码
                  decoration: const InputDecoration(
                    labelText: '\u624b\u673a\u53f7', // "手机号"
                    border: OutlineInputBorder(),
                  ),
                ),
              ),
              const SizedBox(height: 20),
              // 新密码输入框
              Container(
                decoration: BoxDecoration(
                  color: Colors.white.withOpacity(0.8),
                  borderRadius: BorderRadius.circular(10),
                ),
                child: TextField(
                  controller: newPasswordController,
                  obscureText: true, // 密码隐藏
                  decoration: const InputDecoration(
                    labelText: '\u65b0\u5bc6\u7801', // "新密码"
                    border: OutlineInputBorder(),
                  ),
                ),
              ),
              const SizedBox(height: 30),
              // 重置密码按钮
              ElevatedButton(
                onPressed: () {
                  // 验证输入
                  if (usernameController.text.isNotEmpty &&
                      phoneController.text.isNotEmpty &&
                      newPasswordController.text.isNotEmpty) {
                    // 显示重置成功对话框
                    showDialog(
                      context: context,
                      builder: (context) => AlertDialog(
                        title: const Text('\u63d0\u793a'), // "提示"
                        content: const Text(
                            '\u5bc6\u7801\u91cd\u7f6e\u6210\u529f'), // "密码重置成功"
                        actions: [
                          TextButton(
                            onPressed: () {
                              Navigator.pop(context); // 关闭对话框
                              Navigator.pop(context); // 返回登录页
                            },
                            child: const Text('\u786e\u5b9a'), // "确定"
                          ),
                        ],
                      ),
                    );
                  } else {
                    // 显示错误提示
                    showDialog(
                      context: context,
                      builder: (context) => AlertDialog(
                        title: const Text('\u9519\u8bef'), // "错误"
                        content: const Text(
                            '\u8bf7\u586b\u5199\u6240\u6709\u4fe1\u606f'), // "请填写所有信息"
                        actions: [
                          TextButton(
                            onPressed: () => Navigator.pop(context),
                            child: const Text('\u786e\u5b9a'), // "确定"
                          ),
                        ],
                      ),
                    );
                  }
                },
                style: ElevatedButton.styleFrom(
                  foregroundColor: const Color.fromRGBO(255, 0, 0, 1),
                ),
                child: const Text('\u91cd\u7f6e\u5bc6\u7801'), // "重置密码"
              ),
            ],
          ),
        ),
      ),
    );
  }
}
